import { cardCache, toast } from 'nc-lightapp-front';
import config from '../config';
const { setDefData } = cardCache;

export default function (props, key, text, record,index) {
    let rowIndex =  props.cardTable.getAllRows(config.bodycode).length
    switch (key) {
        case 'table_add':
            props.cardTable.addRow(config.bodycode, -1, true);
            //增行时，成本中心和利润中心从表头带下
            let resacostcenter = props.form.getFormItemsValue(config.headcode,'pk_resacostcenter');
            props.cardTable.setValByKeyAndIndex(config.bodycode,rowIndex,'pk_resacostcenter',resacostcenter)
            let pcorg = props.form.getFormItemsValue(config.headcode,'bx_pcorg');
            props.cardTable.setValByKeyAndIndex(config.bodycode,rowIndex,'pk_pcorg',pcorg)
            props.cardTable.setValByKeyAndIndex(config.bodycode,rowIndex,'pk_pcorg_v',pcorg)//zhangXj说利润中心版本先这样取
            break;

        case 'table_delete':
            props.cardTable.delRowsByIndex(config.bodycode, index);
            break;
        default:
            break;
    }
}
